package com.example.gateway.designPattern.proxy.dtdl;

import com.example.gateway.designPattern.proxy.BuyHouseImpl;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @ClassName: DynamicProxyHandler
 * @Description:
 * @Author: YourName
 * @Date: 2024/12/31
 */

public class DynamicProxyHandler implements InvocationHandler {

    private Object object;

    public DynamicProxyHandler(final Object object){
        this.object = object;
    }

    /**
     * @Author: ronghe
     * @Description: invoke
     * @DateTime: 2024/12/31 15:27
     * @Params: proxy , method, args
     * @Return
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("buyHouse---before---");
        Object result = method.invoke(object, args);
        System.out.println("buyHouse---after---");
        return result;
    }
}
